﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VswService_V7.Utility;

namespace VswService_V7.DataBase.Tables
{
    public partial class RECIPE_EVENT
    {
        #region field name 
        public static readonly string tableName = "RECIPE_EVENT";

        public static readonly string fd_recipeName = "RECIPE_NAME";
        public static readonly string fd_recipeNo = "RECIPE_NO";
        public static readonly string fd_machineId = "MACHINE_ID";


        public static readonly string fd_ACC_PR_T_Pressure = "ACC_PR_T_Pressure";
        public static readonly string fd_ACC_PR_B_Pressure = "ACC_PR_B_Pressure";
        public static readonly string fd_EM_C1_SPD = "EM_C1_SPD";
        public static readonly string fd_EM_C1_CHIPLOAD = "EM_C1_CHIPLOAD";
        public static readonly string fd_EM_C2_SPD = "EM_C2_SPD";
        public static readonly string fd_EM_C2_CHIPLOAD = "EM_C2_CHIPLOAD";
        public static readonly string fd_sa1Power = "SA1_POWER";
        public static readonly string fd_sa1Temp = "SA1_TEMP";
        public static readonly string fd_sa1Height = "SA1_HEIGHT";
        public static readonly string fd_sa1Freq = "SA1_FREQ";
        public static readonly string fd_sa2Power = "SA2_POWER";
        public static readonly string fd_sa2Temp = "SA2_TEMP";
        public static readonly string fd_sa2Height = "SA2_HEIGHT";
        public static readonly string fd_sa2Freq = "SA2_FREQ";
        public static readonly string fd_sa3Power = "SA3_POWER";
        public static readonly string fd_sa3Temp = "SA3_TEMP";
        public static readonly string fd_sa3Height = "SA3_HEIGHT";
        public static readonly string fd_sa3Freq = "SA3_FREQ";
        public static readonly string fd_sa4Power = "SA4_POWER";
        public static readonly string fd_sa4Temp = "SA4_TEMP";
        public static readonly string fd_sa4Height = "SA4_HEIGHT";
        public static readonly string fd_sa4Freq = "SA4_FREQ";
        public static readonly string fd_HfwLineSpeed = "HFW_LINESPEED";
        public static readonly string fd_HfwPower = "HFW_POWER";
        public static readonly string fd_HfwFreq = "HFW_FREQ";
        public static readonly string fd_HfwVee_X = "HFW_VEE_X";

        public static readonly string fd_HFW_Mode = "HFW_MODE";
        public static readonly string fd_HFW_PreHeatPower = "HFW_PREHEATPOWER";
        public static readonly string fd_HFW_Temperature = "HFW_TEMPERATURE";
        public static readonly string fd_HFW_SPC_Gain = "HFW_SPC_GAIN";
        public static readonly string fd_HFW_SPC_Slope = "HFW_SPC_SLOP";

        public static readonly string fd_updateDate = "UPDATE_TIME";


        #endregion

        #region Method

        /// <summary>
        /// record one recipe event
        /// </summary>
        /// <param name="recipe"></param>
        /// <returns></returns>
        public static int NewRecipeChangedEvent(RecipeEventINfo recipe)
        {
            string sql = string.Format("insert into {0}" +
                "({1},{2},{3}," +
                "{4},{5}," +
                "{6},{7},{8},{9}," +
                "{10},{11},{12},{13}," +
                "{14},{15},{16},{17}," +
                "{18},{19},{20},{21}," +
                "{22},{23},{24},{25}," +
                "{26},{27},{28},{29}," +
                "{30},{31},{32},{33},{34}," +
                "{35})" +
                "values('{36}','{37}','{38}'," +
                "'{39}','{40}'," +
                "'{41}','{42}','{43}','{44}'," +
                "'{45}','{46}','{47}','{48}'," +
                "'{49}','{50}','{51}','{52}'," +
                "'{53}','{54}','{55}','{56}'," +
                "'{57}','{58}','{59}','{60}'," +
                "'{61}','{62}','{63}','{64}'," +
                "'{65}','{66}','{67}','{68}','{69}'," +
                "'{70}')",
                tableName,
                    fd_recipeName, fd_recipeNo, fd_machineId,
                    fd_ACC_PR_T_Pressure, fd_ACC_PR_B_Pressure,
                    fd_EM_C1_SPD, fd_EM_C1_CHIPLOAD, fd_EM_C2_SPD, fd_EM_C2_CHIPLOAD,
                    fd_sa1Power, fd_sa1Temp, fd_sa1Height, fd_sa1Freq,
                    fd_sa2Power, fd_sa2Temp, fd_sa2Height, fd_sa2Freq,
                    fd_sa3Power, fd_sa3Temp, fd_sa3Height, fd_sa3Freq,
                    fd_sa4Power, fd_sa4Temp, fd_sa4Height, fd_sa4Freq,
                    fd_HfwLineSpeed, fd_HfwPower, fd_HfwFreq, fd_HfwVee_X,
                    fd_HFW_Mode, fd_HFW_PreHeatPower, fd_HFW_Temperature, fd_HFW_SPC_Gain, fd_HFW_SPC_Slope,
                    fd_updateDate,
                    recipe.recipeName, recipe.recipeNo, recipe.machineId,
                    recipe.accPressure_T, recipe.accPressure_B,
                    recipe.emCuttingSpeed_1, recipe.emCuttingChipLoad_1, recipe.emCuttingSpeed_2, recipe.emCuttingChipLoad_2,
                    recipe.sa1Power, recipe.sa1Temp, recipe.sa1Height, recipe.sa1Freq,
                    recipe.sa2Power, recipe.sa2Temp, recipe.sa2Height, recipe.sa2Freq,
                    recipe.sa3Power, recipe.sa3Temp, recipe.sa3Height, recipe.sa3Freq,
                    recipe.sa4Power, recipe.sa4Temp, recipe.sa4Height, recipe.sa4Freq,
                    recipe.hfwLineSpeed, recipe.HfwPower, recipe.HfwFreq, recipe.HfwVee_X,
                    recipe.HFW_Mode, recipe.HFW_PreHeatPower, recipe.HFW_Temperature, recipe.HFW_SPC_Gain, recipe.HFW_SPC_Slope,
                    recipe.updateDate);
            try
            {
                return OracleHelper.Exct_NonQuery(sql);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("NewRecipeChangedEvent", ex);
                throw ex;
            }
        }

        #endregion
    }


    public class RecipeEventINfo
    {
        public RecipeEventINfo()
        {
            recipeName = "0";
            recipeNo = "0";
            machineId = "0";
            accPressure_T = "0";
            accPressure_B = "0";
            emCuttingSpeed_1 = "0";
            emCuttingChipLoad_1 = "0";
            emCuttingSpeed_2 = "0";
            emCuttingChipLoad_2 = "0";
            sa1Power = "0";
            sa1Temp = "0";
            sa1Height = "0";
            sa1Freq = "0";
            sa2Power = "0";
            sa2Temp = "0";
            sa2Height = "0";
            sa2Freq = "0";
            sa3Power = "0";
            sa3Temp = "0";
            sa3Height = "0";
            sa3Freq = "0";
            sa4Power = "0";
            sa4Temp = "0";
            sa4Height = "0";
            sa4Freq = "0";
            hfwLineSpeed = "0";
            HfwPower = "0";
            HfwFreq = "0";
            HfwVee_X = "0";

            HFW_Mode = "0";
            HFW_PreHeatPower = "0";
            HFW_Temperature = "0";
            HFW_SPC_Gain = "0";
            HFW_SPC_Slope = "0";

            updateDate = "0";
        }

        public string recipeName;
        public string recipeNo;
        public string machineId;
        public string accPressure_T;
        public string accPressure_B;
        public string emCuttingSpeed_1;
        public string emCuttingChipLoad_1;
        public string emCuttingSpeed_2;
        public string emCuttingChipLoad_2;
        public string sa1Power;
        public string sa1Temp;
        public string sa1Height;
        public string sa1Freq;
        public string sa2Power;
        public string sa2Temp;
        public string sa2Height;
        public string sa2Freq;
        public string sa3Power;
        public string sa3Temp;
        public string sa3Height;
        public string sa3Freq;
        public string sa4Power;
        public string sa4Temp;
        public string sa4Height;
        public string sa4Freq;
        public string hfwLineSpeed;
        public string HfwPower;
        public string HfwFreq;
        public string HfwVee_X;

        public string HFW_Mode;
        public string HFW_PreHeatPower;
        public string HFW_Temperature;
        public string HFW_SPC_Gain;
        public string HFW_SPC_Slope;

        public string updateDate;
    }

}
